package com.secret.chain.secretchain.service.impl;

import com.secret.chain.secretchain.domain.entity.Collect;
import com.secret.chain.secretchain.mapper.CollectMapper;
import com.secret.chain.secretchain.result.Result;
import com.secret.chain.secretchain.service.CollectService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class CollectServiceImpl implements CollectService {
    @Autowired
    private CollectMapper collectMapper;


    @Override
    public Result queryByUserId(Integer id) {
        Collect collect = collectMapper.queryByUserId(id);
        return Result.success(collect);
    }

    @Override
    public Result save(Collect collect) {
        LocalDateTime now = LocalDateTime.now();
        collect.setCreateTime(now);
        collect.setUpdateTime(now);
        collect.setStatus(1);
        collectMapper.insert(collect);
        return Result.success();
    }

    @Override
    public Result delete(Integer id) {
        collectMapper.delete(id);
        return Result.success();
    }
}
